package com.weige.hotel.mq;

import com.weige.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HotelInfoListener {

    @Autowired
    private IHotelService hotelService;

    /**
     * 监听来自删除队列的消息
     *
     * @param id
     * @throws Exception
     */
    @RabbitListener(queues = "hotel.delete.queue")
    public void receiveDeleteInfo(Long id) throws Exception {
        //删除es下的服务
        hotelService.deleteDocById(id);
    }

    /**
     * 监听来自插入或者更新队列的消息
     *
     * @param id
     * @throws Exception
     */
    @RabbitListener(queues = "hotel.insert.queue")
    public void receiveInsertOrUpdateInfo(Long id) throws Exception {
        //删除es下的服务
        hotelService.insertOrUpdate(id);
    }


}
